package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderIdVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderNoVO;
import com.ssy.lingxi.order.model.vo.basic.request.ShopIdPageVO;
import com.ssy.lingxi.order.model.vo.basic.response.OrderPayChannelDetailVO;
import com.ssy.lingxi.order.model.vo.common.request.*;
import com.ssy.lingxi.order.model.vo.common.response.*;
import com.ssy.lingxi.order.model.vo.vendor.response.VendorOrderDetailVO;
import com.ssy.lingxi.order.service.web.IOrderCommonService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 订单相关的公用接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-29
 */
@RestController
@RequestMapping("/order/common")
public class OrderCommonController {
    @Resource
    private IOrderCommonService orderCommonService;

    /**
     * 商城首页 - 分页查询商品交易记录
     * @param headers HttpHeaders信息
     * @param historyVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderProductHistoryQueryVO>> pageOrderProductHistories(@RequestHeader HttpHeaders headers, @Valid OrderProductHistoryVO historyVO) {
        return orderCommonService.pageOrderProductHistories(headers, historyVO);
    }

    /**
     * 商城首页 - 分页查询商品成交动态
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/shop/product/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderProductShopHistoryVO>> pageOrderProductShopHistories(@RequestHeader HttpHeaders headers, @Valid ShopIdPageVO pageVO) {
        return orderCommonService.pageOrderProductShopHistories(headers, pageVO);
    }

    /**
     * 售后能力 - 查询退货换货商品列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderAfterSalePageQueryVO>> pageAfterSaleOrders(@RequestHeader HttpHeaders headers, @Valid OrderAfterSalePageVO pageVO) {
        return orderCommonService.pageAfterSaleOrders(headers, pageVO);
    }

    /**
     * 售后能力 - “代客售后” - 查询退货换货商品列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/agent/after/sale/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderAfterSalePageQueryVO>> pageAgentAfterSaleOrders(@RequestHeader HttpHeaders headers, @Valid OrderAgentAfterSalePageVO pageVO) {
        return orderCommonService.pageAgentAfterSaleOrders(headers, pageVO);
    }

    /**
     * 售后能力 - 查询已经确认支付结果的支付记录列表
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/payment/find", method = RequestMethod.GET)
    public Wrapper<List<OrderAfterSalePaymentDetailVO>> findAfterSaleOrderPayments(@RequestHeader HttpHeaders headers, @Valid OrderIdVO idVO) {
        return orderCommonService.findAfterSaleOrderPayments(headers, idVO);
    }

    /**
     * 物流能力 - 分页查询“待发货”状态的订单列表
     * @param headers HttpHeaders 信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/logistics/page", method = RequestMethod.GET)
    public Wrapper<PageData<LogisticsOrderQueryVO>> pageLogisticsOrders(@RequestHeader HttpHeaders headers, @Valid OrderLogisticsPageVO pageVO) {
        return orderCommonService.pageLogisticsOrders(headers, pageVO);
    }

    /**
     * 物流能力 - 根据订单Id，分页查询订单商品列表
     * @param headers HttpHeaders 信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/logistics/page", method = RequestMethod.GET)
    public Wrapper<PageData<LogisticsOrderProductQueryVO>> pageLogisticsOrderProducts(@RequestHeader HttpHeaders headers, @Valid OrderProductLogisticsPageVO pageVO) {
        return orderCommonService.pageLogisticsOrderProducts(headers, pageVO);
    }

    /**
     * 加工能力 - 分页查询加工订单列表
     * @param headers HttpHeaders信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/enhance/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderEnhancePageQueryVO>> pageEnhanceOrders(@RequestHeader HttpHeaders headers, @Valid OrderEnhancePageVO pageVO) {
        return orderCommonService.pageEnhanceOrders(headers, pageVO);
    }

    /**
     * 支付能力 - 查询会员支付渠道列表
     * @param headers HttpHeaders信息
     * @param payTypeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/pay/channels", method = RequestMethod.GET)
    public Wrapper<List<OrderPayChannelDetailVO>> findMemberPayChannels(@RequestHeader HttpHeaders headers, @Valid OrderMemberPayTypeVO payTypeVO) {
        return orderCommonService.findMemberPayChannels(headers, payTypeVO);
    }

    /**
     * 结算能力 - 开票管理 - 根据订单号查看订单详情
     * @param headers HttpHeaders信息
     * @param orderVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/settle/order/detail", method = RequestMethod.GET)
    public Wrapper<VendorOrderDetailVO> findSettleOrderDetailByOrderNo(@RequestHeader HttpHeaders headers, @Valid OrderNoVO orderVO) {
        return orderCommonService.findSettleOrderDetailByOrderNo(headers, orderVO);
    }

    /**
     * 商品能力 - 上架指引查询商品是否配置了交易流程
     * @param headers HttpHeaders信息
     * @param processVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/process/find", method = RequestMethod.POST)
    public Wrapper<List<OrderProductProcessQueryVO>> findProductProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProductProcessVO processVO) {
        return orderCommonService.findProductProcess(headers, processVO);
    }
}
